package com.hontech.bread.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bread.R
import com.hontech.bread.device.mdb.Coin
import com.hontech.bread.ui.dialog.runProg
import com.hontech.bread.ui.view.LabelInput
import com.hontech.bread.utils.onClick
import com.hontech.bread.utils.stringById

class CoinTestParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {


    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_coin_test, this)

        val li = view.findViewById<LabelInput>(R.id.id_coin_test_li_payout)
        val btn = view.findViewById<Button>(R.id.id_coin_test_btn_payout)

        btn.onClick {
            runProg(stringById(R.string.text_15), stringById(R.string.text_16)) {
                Coin.change(li.textInt())
            }
        }
    }
}